package cn.tx.erp.bus.controller;

import cn.tx.erp.bus.domain.Provider;
import cn.tx.erp.bus.service.ProviderService;
import cn.tx.erp.bus.vo.ProviderVo;
import cn.tx.erp.sys.utils.DataGridView;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author Mxb
 * @version 1.0
 * @date 2020/7/12 16:39
 */
@RestController
@RequestMapping("/provider")
public class ProviderController {

    @Autowired
    private ProviderService providerService;

    /**
     * 查询所有的供应商
     *
     * @param providerVo
     * @return
     */
    @RequestMapping("/loadAllProvider")
    public DataGridView loadAllGoods(ProviderVo providerVo) {
        // 分页
        IPage<Provider> page = new Page<>(providerVo.getPage(), providerVo.getLimit());
        // 条件
        QueryWrapper<Provider> qw = new QueryWrapper<>();
        //qw.like(StringUtils.isNotBlank(goodsVo.getCustomername()), "customername", customerVo.getCustomername());
        qw.orderByAsc("id");

        this.providerService.page(page, qw);

        return new DataGridView(0, "", page.getTotal(), page.getRecords());
    }
}
